package net.flyinggroup.kafka.avro;

import com.flying.kafka.Cat;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.integration.config.GlobalChannelInterceptor;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.ChannelInterceptor;

import java.util.function.Consumer;

@SpringBootApplication
public class DataConsumer {
    public static void main(String[] args) {
        SpringApplication.run(DataConsumer.class, args);
    }

    @Bean
    public Consumer<Message<Cat>> avroMsg() {
        return value -> {
            System.out.println("Received: " + value);
        };
    }

    @Bean
    @GlobalChannelInterceptor
    public ChannelInterceptor consumerChannelInterceptor() {
        return new ConsumerChannelInterceptor();
    }
}
